package s19.ch22.ex3;

import java.awt.BorderLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class MyActionList {

	public static void main(String[] args) {
		JFrame jFrame = new JFrame();
		JPanel jPanel = new JPanel();
		JButton jButton1 = new JButton();
		JButton jButton2 = new JButton();
		jFrame.add(jPanel);
		jPanel.add(jButton1);
		jPanel.add(jButton2);
		
		final JLabel jLabel = new JLabel();
		jFrame.add(jLabel, BorderLayout.SOUTH);
		ActionListener listener1 = new ActionListenerImplementation(jLabel);
		jButton1.addActionListener(listener1);
		ActionListener listener2 = new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				jLabel.setText("button2 has been press");
				
			}
		};
		jButton2.addActionListener(listener2);
		JButton jButton3 = new JButton();
		final JTextField jTextField = new JTextField(10);
		jPanel.add(jTextField);
		jPanel.add(jButton3);
		ActionListener listener3 = new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				String text = jTextField.getText();
				jLabel.setText(text);
				
			}
		};
		jButton3.addActionListener(listener3);
		
		
		

		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jFrame.setSize(400, 200);
		jFrame.setVisible(true);

	}

}
